package application.view 
{
	import application.ApplicationFacade;
	import application.model.VO.GroupVO;
	import application.model.VO.PhotoAreaVO;
	import application.view.viewComponent.PhotoArea;
	import application.view.viewComponent.GroupCombobox;
	import ginger.events.DataEvent;
	import flash.events.Event;
	import org.puremvc.as3.interfaces.IMediator;
	import org.puremvc.as3.interfaces.INotification;
	import org.puremvc.as3.patterns.mediator.Mediator;
	
	/**
	 * ...
	 * @author Ning
	 */
	public class PhotoAreaMediator extends Mediator implements IMediator
	{
		public static const NAME:String = 'PhotoAreaMediator';
		public function PhotoAreaMediator(viewComponent:PhotoArea) 
		{
			super(NAME, viewComponent);
			photoArea.addEventListener(PhotoArea.SELECT_ITEM, onSelectItem);
		}
		private function get photoArea():PhotoArea {
			return viewComponent as PhotoArea;
		}
		
		override public function handleNotification(notification:INotification):void 
		{
			switch(notification.getName())
			{
				case ApplicationFacade.UPDATE_PIC_AREA_CONFIG:
				photoArea.updateConfig(notification.getBody() as PhotoAreaVO);
				break;
				case ApplicationFacade.UPDATE_PIC_AREA_DATA:
				photoArea.updateData(notification.getBody() as Array);
				break;
			}
		}
		override public function listNotificationInterests():Array 
		{
			return [ApplicationFacade.UPDATE_PIC_AREA_CONFIG, ApplicationFacade.UPDATE_PIC_AREA_DATA];
		}
		
		private function onSelectItem(evt:DataEvent):void
		{
			sendNotification(ApplicationFacade.SHOW_PHOTO_VIEW, evt.data);
		}
	}
}